import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

/**
 * @Author zk
 * @Date 2017/6/16.
 * @Email 2117251154@qq.com
 */
public class Start {
    public static void main(String[] ags) throws Exception {
        Server server = new Server(8080);
        WebAppContext webAppContext = new WebAppContext();
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        String webappDirPath = classLoader.getResource("").getPath().replaceAll("target/classes","src/main/webapp");
        webAppContext.setContextPath("/");
        webAppContext.setClassLoader(classLoader);//类加载路径
        webAppContext.setResourceBase(classLoader.getResource("").getPath());
        webAppContext.setDescriptor(webappDirPath + "/WEB-INF/web.xml");
        webAppContext.setParentLoaderPriority(true);
        server.setHandler(webAppContext);
        server.start();
    }
}
